Merge pull request #370 from alias1/weatheragent-tweaks

Weatheragent - Make expected_update_period_in_days an option

Andrew Cantino 10 years ago
parent
commit
c2f7b8a041
1 changed files with 6 additions and 3 deletions
  1. 6 3
      app/models/agents/weather_agent.rb

+ 6 - 3
app/models/agents/weather_agent.rb

@@ -19,6 +19,8 @@ module Agents
19 19
       You must setup an [API key for Wunderground](http://www.wunderground.com/weather/api/) in order to use this Agent with Wunderground.
20 20
 
21 21
       You must setup an [API key for Forecast](https://developer.forecast.io/) in order to use this Agent with ForecastIO.
22
+
23
+      Set `expected_update_period_in_days` to the maximum amount of time that you'd expect to pass between Events being created by this Agent.
22 24
     MD
23 25
 
24 26
     event_description <<-MD
@@ -49,7 +51,7 @@ module Agents
49 51
     default_schedule "8pm"
50 52
 
51 53
     def working?
52
-      event_created_within?(2) && !recent_error_logs?
54
+      event_created_within?((options['expected_update_period_in_days'].presence || 2).to_i) && !recent_error_logs?
53 55
     end
54 56
 
55 57
     def key_setup?
@@ -61,7 +63,8 @@ module Agents
61 63
         'service' => 'wunderground',
62 64
         'api_key' => 'your-key',
63 65
         'location' => '94103',
64
-        'which_day' => '1'
66
+        'which_day' => '1',
67
+        'expected_update_period_in_days' => '2'
65 68
       }
66 69
     end
67 70
 
@@ -163,7 +166,7 @@ module Agents
163 166
               'ozone' => value.ozone.to_s
164 167
             }
165 168
             return day
166
-          end    
169
+          end
167 170
         end
168 171
       end
169 172
     end